home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
graphic
/
hpglvu10.zip
/
HPGLVIEW.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-04-18
|
33KB
|
999 lines
program HPGLVIEW;
{-----------------------------------------------------------------------------}
(* An HPGL viewer
The viewer takes a file of HPGL commands and displays the plot commands
on the screen.
It always represents the page (A3 or A4) lying sideways on the
screen, to preserve the maximum resolution, and ignores the aspect ratio
of the screen for the same reason.
Its designed to show you what the plot looks like on the page not be
an absolute mimic of a plot. If you need absolute precision, plot it.
-------------------------------------------------------------------------------
HPGLVIEW - a on-screen Previewer for HPGL files
Copyright (C) 1991 Giovanni S. Moretti
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-----------------------------------------------------------------------------
Giovanni Moretti | EMAIL: G.Moretti@massey.ac.nz
Computer Centre, Massey University |
Palmerston North, New Zealand |
-----------------------------------------------------------------------------
Please send me a copy of any major hacks/improvements so I can coordinate
any new releases.
HP-GL is (probably) a trademark of Hewlett-Packard Company.
*)
{-----------------------------------------------------------------------------}
{ RCS Control Information
$Author: Giovanni_Moretti $
$Date: 91/04/18 15:57:59 $
$Revision: 1.1 $
$Log: hpglview.pas $
Revision 1.1 91/04/18 15:57:59 ROOT_DOS
Initial revision
}
uses graph, dos, crt, smalfont, { Like FONTS.PAS with only SMALLFONT left}
drivers;
const A3_char_width = 0.285; {cm}
A3_char_height = 0.375;
A4_char_width = 0.187;
A4_char_height = 0.269;
unknown_max = 100;
var pen_down : boolean;
cmd : string; {Current HPGL command being done}
x, y, x1,y1 : real; {and the numeric arguments to this cmd}
lbl : string; {or a character string arg for LB cmd }
filename : string;
inf : text; {Input file}
screen_max_X : integer; {No of dots across screen -1}
screen_max_Y : integer; {and number down }
Graphics_Driver : integer; { for BGI - may be set manually with /G }
Graphics_mode : integer; { for BGI - may be set manually with /G }
{-----------------------------------------------------------------------------}
use_plotter_units : boolean; {If TRUE => NO Scaling, FALSE => Scale}
x_max : real; {Maximum and Minimum values as defined}
x_min : real; {by the SC (Scale) command }
y_max : real;
y_min : real;
x_p1, y_p1 : integer;
x_p2, y_p2 : integer;
{-----------------------------------------------------------------------------}
Paper_size : integer; {Either a 3 or 4 (A3 or A4) }
X_plot_area_mm : integer;
Y_plot_area_mm : integer;
args : boolean;
hard_clip_X : integer;
hard_clip_Y : integer;
colour : integer; {Current colour from video palette}
{-----------------------------------------------------------------------------}
char_height : real; {Currently set Character Height and Width}
char_width : real; {Always defined - used by SI and DI cmds }
text_direction : word; {Used by DI cmd }
{-----------------------------------------------------------------------------}
symbol_mode : boolean; {Whether a symbol is drawn on a PA or PR }
symbol_char : char; {command - used by the SM instruction }
{-----------------------------------------------------------------------------}
{Remember unimplemented commands in this array for later }
unknown_cmds : array [1..unknown_max] of string;
unknown_count : integer;
cnt : integer;
pause : char;
ch : char;
debug : boolean;
digits : set of char;
i : integer; {General Purpose Integer}
finished : boolean;
initialise_cmd_count : integer; {Used to pause on 2nd, 3rd ... IN cmd}
IP_cmd_count : integer; {Used to change colours on 2nd .. IP cmd}
auto_detect_graphics : boolean; {altered be /G command line option }
{-----------------------------------------------------------------------------}
procedure SET_DEFAULT_TEXT_DIRECTION;
begin
text_Direction:= HorizDir;
SetTextJustify(LeftText, BottomText);
end;
{-----------------------------------------------------------------------------}
{ Set up the appropriate scaling factors to draw text of the size defined by
HEIGHT and WIDTH.
HEIGHT and WIDTH are remembered in CHAR_HEIGHT and CHAR_WIDTH so
this procedure can be reused if TEXT_DIRECTION is redefined.
This procedure is used whenever it is necessary to change either
text size or direction.
}
procedure SET_TEXT_SIZE (width, height : real); {Arguments are in Centimetres}
var x_top, x_bottom, y_top, y_bottom : integer;
width_in_mm, height_in_mm : real;
scale_x, scale_y : real;
letter_height, letter_width : integer;
begin
{Scale ratios by 100 so as not to lose too much precision on ROUND()}
x_top:= 100; x_bottom:= 100; y_top:= 100; y_bottom:= 100;
{This Section Gives "Approximately" the correct size lettering }
SetTextStyle(SmallFont, HorizDir, 2);
letter_height:= TextHeight('M'); {Remember Size of Standard Characters}
letter_width := TextWidth('M');
width_in_mm := letter_width / screen_max_X * X_plot_area_mm;
scale_x:= (width*10) / width_in_mm; { *10 as SI args are in cm}
if scale_x > 10 then scale_x:= 10;
if scale_X > 1 then x_top := round(scale_x *100)
else x_bottom:= round(1/scale_X *100);
height_in_mm:= Letter_Height / screen_max_Y * Y_plot_area_mm;
scale_y:= (height*10) / height_in_mm; { *10 as SI args are in cm}
if scale_y > 10 then scale_y:= 10;
if scale_y > 1 then Y_top := round(scale_Y *100)
else Y_bottom:= round(1/scale_Y *100);
SetUserCharSize(x_top, x_bottom, y_top, y_bottom);
SetTextStyle(smallFont, text_direction, UserCharSize);
end;
{-----------------------------------------------------------------------------}
procedure SET_DEFAULT_TEXT_SIZE;
begin
if paper_size = 4 then { A4 Paper }
begin
char_height := A4_char_height;
char_width := A4_char_width;
end
else { A3 Paper }
begin
char_width := A3_char_width;
char_height := A3_char_height;
end;
set_text_size(char_width, char_height);
end;
{-----------------------------------------------------------------------------}
procedure SET_P1_P2 (x, y, x1, y1 : integer);
begin
x_p1:= x;
y_p1:= y;
x_p2:= x1;
y_p2:= y1;
end;
{-----------------------------------------------------------------------------}
procedure SET_DEFAULT_P1_P2;
begin
if paper_size = 4 then { A4 Paper }
begin
x_p2 := 10430;
x_p1 := 430;
y_p2 := 7400;
y_p1 := 20